ALMaSS  1.0
The Animal, Landscape and Man Simulation System
Newt_Adult Class Reference

The newt adult class - contains behaviour and attributes common to adults but not juveniles. More...

#include <Newt.h>

Inheritance diagram for Newt_Adult:
Newt_Juvenile Newt_Base TAnimal TALMaSSObject Newt_Female Newt_Male

Public Member Functions

 Newt_Adult (int a_x, int a_y, vector< unsigned > a_pond, Landscape *a_L, Newt_Population_Manager *a_NPM, unsigned a_age, bool a_reproinhib)
 Newt_Adult constructor. More...
 
 ~Newt_Adult ()
 Newt_Male destructor. More...
 
virtual void Init (int a_x, int a_y, vector< unsigned > a_pond, Landscape *a_L, Newt_Population_Manager *a_NPM, unsigned a_age)
 Initialise object. More...
 
virtual void ReInit (int a_x, int a_y, vector< unsigned > a_pond, Landscape *a_L, Newt_Population_Manager *a_NPM, unsigned a_age, bool a_reproinhib)
 Used to re-use an object - must be implemented in descendent classes. More...
 
int GetInPond ()
 Returns the current pond status (-1 if not in pond else the pond ref is returned) More...
 
void SetInPond ()
 Forces setting the in pond status to the first pond ref - used only on start-up. More...
 
- Public Member Functions inherited from Newt_Juvenile
 Newt_Juvenile (int a_x, int a_y, vector< unsigned > a_pond, Landscape *a_L, Newt_Population_Manager *a_NPM, unsigned a_age, bool a_reproinhib)
 Newt_Juvenile constructor. More...
 
 ~Newt_Juvenile ()
 Newt_Juvenile destructor. More...
 
virtual void Step (void)
 Newt_Juvenile Step code. This is called continuously until all animals report that they are 'DONE'. More...
 
double GetWeight ()
 Get method for m_weight. More...
 
void SetWeight (double a_weight)
 Set method for m_weight. More...
 
void InternalPesticideHandlingAndResponse ()
 For handlng of class-specific pesticide effects. More...
 
- Public Member Functions inherited from Newt_Base
 Newt_Base (int a_x, int a_y, vector< unsigned > a_pond, Landscape *a_L, Newt_Population_Manager *a_NPM, bool a_reproinhib)
 Newt constructor. More...
 
void Init (vector< unsigned > a_pond, Newt_Population_Manager *a_NPM, bool a_reproinhib)
 Intitialise object. More...
 
void ReInit (int a_x, int a_y, vector< unsigned > a_pond, Landscape *a_L, Newt_Population_Manager *a_NPM, bool a_reproinhib)
 ReInit for object pool. More...
 
 ~Newt_Base ()
 Newt destructor. More...
 
virtual int WhatState ()
 Returns the state number for display purposes. More...
 
TTypeOfNewtState st_Develop (void)
 Behavioural state development - does nothing in the base class. More...
 
TTypeOfNewtState st_Movement (void)
 Behavioural state movement - does nothing in the base class. More...
 
void st_Dying (void)
 Behavioural state dying. More...
 
virtual void BeginStep (void)
 The BeginStep is the first 'part' of the timestep that an animal can behave in. It is called once per timestep. More...
 
virtual void EndStep (void)
 The EndStep is the third 'part' of the timestep that an animal can behave in. It is called once per timestep. More...
 
unsigned GetAge ()
 A typical interface function - this one returns the Age as an unsigned integer. More...
 
void SetAge (unsigned a_age)
 A typical interface function - this one sets the Age as an unsigned integer. More...
 
unsigned GetHomePond ()
 A typical interface function - this one returns the home pond reference as an unsigned integer. More...
 
void SetHomePond (unsigned a_pond)
 A typical interface function - this one sets the home pond reference as an unsigned integer. More...
 
void InternalPesticideHandlingAndResponse (double)
 For handlng of class-specific pesticide effects. More...
 
- Public Member Functions inherited from TAnimal
unsigned SupplyFarmOwnerRef ()
 
AnimalPosition SupplyPosition ()
 
APoint SupplyPoint ()
 
int SupplyPolygonRef ()
 
int Supply_m_Location_x ()
 
int Supply_m_Location_y ()
 
virtual void KillThis ()
 
virtual void CopyMyself ()
 
void SetX (int a_x)
 
void SetY (int a_y)
 
 TAnimal (int x, int y, Landscape *L)
 
virtual void ReinitialiseObject (int x, int y, Landscape *L)
 Used to re-use an object - must be implemented in descendent classes. More...
 
virtual void Dying ()
 
void CheckManagement (void)
 
void CheckManagementXY (int x, int y)
 
virtual bool OnFarmEvent (FarmToDo)
 
- Public Member Functions inherited from TALMaSSObject
int GetCurrentStateNo ()
 Returns the current state number. More...
 
void SetCurrentStateNo (int a_num)
 Sets the current state number. More...
 
bool GetStepDone ()
 Returns the step done indicator flag. More...
 
void SetStepDone (bool a_bool)
 Sets the step done indicator flag. More...
 
virtual void ReinitialiseObject ()
 Used to re-use an object - must be implemented in descendent classes. More...
 
 TALMaSSObject ()
 The constructor for TALMaSSObject. More...
 
virtual ~TALMaSSObject ()
 The destructor for TALMaSSObject. More...
 
void OnArrayBoundsError ()
 Used for debugging only, tests basic object properties. More...
 

Static Public Attributes

static double m_AdultPPPThreshold = cfg_NewtAdultPPPToxTrigger.value()
 The threshold for effect of PPP on adults. More...
 
static double m_AdultPPPElimRate = cfg_NewtAdultPPPToxEliminationRate.value()
 The daily proportion of PPP body burden that is not eliminated for adults. More...
 
static double m_AdultPPPEffectProbability = cfg_NewtAdultPPPEffectProbability.value()
 The daily probability of effect if above m_AdultPPPThreshold for adults. More...
 
static unsigned m_AdultLifespan = cfg_NewtAdultLifespan.value()
 
static int m_newtadultwalkspeed = cfg_NewtWalkSpeed.value()/10
 The max walking speed of a newt. More...
 
- Static Public Attributes inherited from Newt_Juvenile
static double m_JuvenilePPPThreshold_Min = 0
 The minimum threshold for effect of PPP on juveniles. More...
 
static double m_JuvenilePPPThreshold_EnvConc = cfg_NewtJuvenilePPPToxTrigger_EnvConc.value()
 The environmental concentration threshold for effect of PPP on juveniles. More...
 
static double m_JuvenilePPPThreshold_Overspray = cfg_NewtJuvenilePPPToxTrigger_Overspray.value()
 The overspray threshold for effect of PPP on juveniles. More...
 
static double m_JuvenilePPPElimRate = cfg_NewtJuvenilePPPToxEliminationRate.value()
 The daily proportion of PPP body burden that is not eliminated for juveniles. More...
 
static double m_JuvenilePPPEffectProbability_EnvConc = cfg_NewtJuvenilePPPEffectProbability_EnvConc.value()
 The daily probability of effect if above m_JuvenilePPPThreshold for juveniles for environmental concentration. More...
 
static double m_JuvenilePPPEffectProbability_Overspray = cfg_NewtJuvenilePPPEffectProbability_Overspray.value()
 The daily probability of effect if above m_JuvenilePPPThreshold for juveniles for overspray. More...
 
static double m_JuvenileDailyWeightGain = cfg_NewtJuvenileDailyLengthGain.value()
 Used in determining daily growth. More...
 
static int m_SimW = 0
 The width of the simulation map, stored for fast access. More...
 
static int m_SimH = 0
 The height of the simulation map, stored for fast access. More...
 
static double m_roadmortalityprob = cfg_NewtRoadMortalityProb.value()
 The probability of death when crossing a road. More...
 
static int m_newtwalkspeed = cfg_NewtWalkSpeed.value()
 The max walking speed of a newt. More...
 
static int m_newtwalkstepsize = cfg_NewtWalkStepsize.value()
 The size of a step when evaluating habitat during walking. More...
 
static double m_goodhabitatdispersalprob = cfg_newtgoodhabitatdispersalprob.value()
 Probability of dispersal in good habitat. More...
 
static double m_poorhabitatdispersalprob = cfg_newtpoorhabitatdispersalprob.value()
 Probability of dispersal in poor habitat. More...
 
static double m_NewtDormancyTemperature = cfg_newtdormancytemp.value()
 Temperature in degrees that the newts become dormant. More...
 
static double m_NewtDormancyHumidity = cfg_newtdormancyhumidity.value()
 Temperature in degrees that the newts become dormant. More...
 
- Static Public Attributes inherited from Newt_Base
static double m_EggDevelopmentDDTotal = cfg_NewtEggDevelTotal.value()
 
static double m_EggDevelopmentDDParameter = cfg_NewtEggDevelDDParameter.value()
 
static double m_JuvenileDevelopmentSize = cfg_NewtJuvenileDevelSize.value()
 
static double m_EggMortalityChance = cfg_NewtEggMortalityChance.value()
 
static double m_JuvenileMortalityChance = 0.0
 
static double m_AdultMortalityChance = 0.0
 
static bool m_test_pesticide_egg = cfg_Newt_Test_Pesticide_Egg.value()
 Flags to record whether we are in pesticide testing mode. More...
 
static bool m_test_pesticide_larva = cfg_Newt_Test_Pesticide_Larva.value()
 
static bool m_test_pesticide_terrestrial = cfg_Newt_Test_Pesticide_Terrestrial.value()
 

Protected Member Functions

void CalcMovementVector (void)
 Calculates the direction needed to move in to get to the target pond. More...
 
bool AgeMortTest (void)
 Ages the adult and applies a daily mortality probability. More...
 
virtual TTypeOfNewtState st_Develop (void)
 Adult development state. More...
 
virtual TTypeOfNewtState st_Disperse (void)
 Adult development state. More...
 
virtual TTypeOfNewtState st_Overwinter (void)
 Adult dormant state. More...
 
virtual TTypeOfNewtState st_Migrate (void)
 Adult migration to pond state. More...
 
virtual TTypeOfNewtState st_EvaluateHabitat (void)
 Adult evaluate habitat behaviour. More...
 
- Protected Member Functions inherited from Newt_Juvenile
virtual TTypeOfNewtState st_NextStage (void)
 Juvenile maturation. More...
 
void MoveTo (TTypeDirectedWalk a_directedness, int a_stepsize, int a_steps)
 Top level control of newt movement. More...
 
void NewtDoWalking (int &a_vector, int a_stepsize, int a_steps, int &vx, int &vy)
 This method moves the newt through the landscape. More...
 
void NewtDoWalkingCorrect (int &a_vector, int a_stepsize, int a_steps, int &vx, int &vy)
 This method moves the newt through the landscape using wrap around corrects. More...
 
int NewtMoveQuality (int a_x, int a_y, TTypesOfLandscapeElement &a_tole)
 Tests the habitat quality for a square to move to. More...
 
- Protected Member Functions inherited from TAnimal
void CorrectWrapRound ()
 Corrects wrap around co-ordinate problems. More...
 

Protected Attributes

int m_targetpondx
 x-coord of a target pond More...
 
int m_targetpondy
 y-coord of a target pond More...
 
- Protected Attributes inherited from Newt_Juvenile
int m_InPond
 The polyrefindex for the pond the newt is in, or -1 if not in a pond. More...
 
double m_weight
 
unsigned m_OurVector
 The last direction we moved in. More...
 
TTypesOfLandscapeElement m_CurrentHabitat
 The current habitat type the newt is in. More...
 
bool m_forcedisperse
 A flag to force dispersal from the breeding ponds. More...
 
- Protected Attributes inherited from Newt_Base
TTypeOfNewtState m_CurrentNewtState
 Variable to record current behavioural state. More...
 
unsigned m_Age
 
vector< unsigned > m_pondlist
 
Newt_Population_Managerm_OurPopulationManager
 This is a time saving pointer to the correct population manager object. More...
 
double m_body_burden
 The current PPP body burden for use in pesticide testing mode. More...
 
bool m_reproductiveinhibition
 A flag to indicate environmentally induced reproductive inhibition (value is inherited by descendent classes) More...
 
- Protected Attributes inherited from TAnimal
int m_Location_x
 
int m_Location_y
 
Landscapem_OurLandscape
 
- Protected Attributes inherited from TALMaSSObject
int m_CurrentStateNo
 The basic state number for all objects - '-1' indicates death. More...
 
bool m_StepDone
 Indicates whether the iterative step code is done for this timestep. More...
 

Detailed Description

The newt adult class - contains behaviour and attributes common to adults but not juveniles.

Constructor & Destructor Documentation

◆ Newt_Adult()

Newt_Adult::Newt_Adult ( int  a_x,
int  a_y,
vector< unsigned >  a_pond,
Landscape a_L,
Newt_Population_Manager a_NPM,
unsigned  a_age,
bool  a_reproinhib 
)

Newt_Adult constructor.

690  : Newt_Juvenile(a_x, a_y, a_pond, a_L, a_NPM, a_age, a_reproinhib)
691 {
692  Init(a_x, a_y, a_pond, a_L, a_NPM, a_age);
693 }
virtual void Init(int a_x, int a_y, vector< unsigned > a_pond, Landscape *a_L, Newt_Population_Manager *a_NPM, unsigned a_age)
Initialise object.
Definition: Newt.cpp:707
Newt_Juvenile(int a_x, int a_y, vector< unsigned > a_pond, Landscape *a_L, Newt_Population_Manager *a_NPM, unsigned a_age, bool a_reproinhib)
Newt_Juvenile constructor.
Definition: Newt.cpp:326

References Init().

◆ ~Newt_Adult()

Newt_Adult::~Newt_Adult ( void  )

Newt_Male destructor.

696  {
697  ;
698 }

Member Function Documentation

◆ AgeMortTest()

bool Newt_Adult::AgeMortTest ( void  )
protected

Ages the adult and applies a daily mortality probability.

Ages the adult and tests for daily mortality using the supplied parameter for daily adult mortality stored in m_AdultMortalityChance. This function is used by st_Develop, st_Overwinter and Newt_Female::st_Breed behaviours.

768  {
773  if (g_rand_uni() < m_AdultMortalityChance) return true;
774  m_Age++;
775  if (m_Age > m_AdultLifespan) return true;
776  return false;
777 }
boost::variate_generator< base_generator_type &, boost::uniform_real<> > g_rand_uni
static unsigned m_AdultLifespan
Definition: Newt.h:417
static double m_AdultMortalityChance
Definition: Newt.h:104
unsigned m_Age
Definition: Newt.h:115

References g_rand_uni, m_AdultLifespan, Newt_Base::m_AdultMortalityChance, and Newt_Base::m_Age.

Referenced by Newt_Female::st_Breed(), st_Develop(), and st_Overwinter().

◆ CalcMovementVector()

void Newt_Adult::CalcMovementVector ( void  )
inlineprotected

Calculates the direction needed to move in to get to the target pond.

This is a very simple direction calculator. It will fail if the pond is over a wrap around boundary. To simplify this we only assume diagonal movement.

874  {
879  int dx = m_targetpondx - m_Location_x;
880  int dy = m_targetpondy - m_Location_y;
881  if (dx > 0)
882  if (dy > 0) m_OurVector = direction_se;
883  else m_OurVector = direction_ne;
884  else if (dy > 0) m_OurVector = direction_sw;
885  else m_OurVector = direction_nw;
886 }
int m_targetpondx
x-coord of a target pond
Definition: Newt.h:440
int m_targetpondy
y-coord of a target pond
Definition: Newt.h:442
unsigned m_OurVector
The last direction we moved in.
Definition: Newt.h:367
int m_Location_y
Definition: PopulationManager.h:228
int m_Location_x
Definition: PopulationManager.h:225
@ direction_se
Definition: landscape.h:60
@ direction_nw
Definition: landscape.h:60
@ direction_ne
Definition: landscape.h:60
@ direction_sw
Definition: landscape.h:60

References direction_ne, direction_nw, direction_se, direction_sw, TAnimal::m_Location_x, TAnimal::m_Location_y, Newt_Juvenile::m_OurVector, m_targetpondx, and m_targetpondy.

Referenced by st_Migrate().

◆ GetInPond()

int Newt_Adult::GetInPond ( )
inline

Returns the current pond status (-1 if not in pond else the pond ref is returned)

430  {
431  return m_InPond;
432  }
int m_InPond
The polyrefindex for the pond the newt is in, or -1 if not in a pond.
Definition: Newt.h:363

References Newt_Juvenile::m_InPond.

◆ Init()

void Newt_Adult::Init ( int  a_x,
int  a_y,
vector< unsigned >  a_pond,
Landscape a_L,
Newt_Population_Manager a_NPM,
unsigned  a_age 
)
virtual

Initialise object.

Newt_Adult Initialise object, assigns default values to specific adult attributes for in pond and target pond for migration, and passes the age to the Newt_Juvenile constructor.

707  {
712  int apolyref = a_L->SupplyPolyRefIndex(a_x, a_y);
713  if (a_L->SupplyElementTypeFromVector(apolyref) != tole_Pond)
714  m_InPond = -1;
715  else {
716  m_InPond = apolyref;
717  }
718  m_targetpondx = -1;
719  m_targetpondy = -1;
720 #ifdef __RECORDNEWTMETAMORPHOSIS
721  a_NPM->RecordAdultProduction(a_age);
722 #endif
723 }
TTypesOfLandscapeElement SupplyElementTypeFromVector(unsigned int a_index)
Definition: landscape.h:1104
int SupplyPolyRefIndex(int a_x, int a_y)
Definition: landscape.h:1493
void RecordAdultProduction(int a_adult)
Add a new adult to the stats record.
Definition: Newt_Population_Manager.cpp:456
@ tole_Pond
Definition: tole_declaration.h:101

References Newt_Juvenile::m_InPond, m_targetpondx, m_targetpondy, Newt_Population_Manager::RecordAdultProduction(), Landscape::SupplyElementTypeFromVector(), Landscape::SupplyPolyRefIndex(), and tole_Pond.

Referenced by Newt_Adult(), and ReInit().

◆ ReInit()

void Newt_Adult::ReInit ( int  a_x,
int  a_y,
vector< unsigned >  a_pond,
Landscape a_L,
Newt_Population_Manager a_NPM,
unsigned  a_age,
bool  a_reproinhib 
)
virtual

Used to re-use an object - must be implemented in descendent classes.

Reimplemented from Newt_Juvenile.

Reimplemented in Newt_Female, and Newt_Male.

701  {
702  Newt_Juvenile::ReInit(a_x, a_y, a_pond, a_L, a_NPM, a_age, a_reproinhib);
703  Init(a_x, a_y, a_pond, a_L, a_NPM, a_age);
704 }
virtual void ReInit(int a_x, int a_y, vector< unsigned > a_pond, Landscape *a_L, Newt_Population_Manager *a_NPM, unsigned a_age, bool a_reproinhib)
Used to re-use an object - must be implemented in descendent classes.
Definition: Newt.cpp:344

References Init(), and Newt_Juvenile::ReInit().

Referenced by Newt_Male::ReInit(), and Newt_Female::ReInit().

◆ SetInPond()

void Newt_Adult::SetInPond ( )
inline

Forces setting the in pond status to the first pond ref - used only on start-up.

434  {
435  m_InPond = m_pondlist[0];
436  }
vector< unsigned > m_pondlist
Definition: Newt.h:117

References Newt_Juvenile::m_InPond, and Newt_Base::m_pondlist.

◆ st_Develop()

TTypeOfNewtState Newt_Adult::st_Develop ( void  )
protectedvirtual

Adult development state.

First determines whether the newt sucumbs to daily mortality, if so return toNewts_Die state.
If the adult survives:

  • The age is incremented
  • If the total age exceeds the parameter value held in m_AdultLifespan, the newt dies
  • the behavioural state st_EvaluateHabitat is called following st_Develop, which leads to either a dispersal state or return to this state on the next day.

Reimplemented from Newt_Juvenile.

Reimplemented in Newt_Female, and Newt_Male.

751  {
760  if (AgeMortTest()) return toNewts_Die;
762  return toNewts_Overwinter;
763  }
765 }
@ toNewts_EvaluateLocation
Definition: Newt.h:68
@ toNewts_Die
Definition: Newt.h:75
@ toNewts_Overwinter
Definition: Newt.h:74
class Calendar * g_date
Definition: calendar.cpp:38
long Date(void)
Definition: calendar.h:57
double SupplyTempPeriod(long a_date, int a_period)
Definition: landscape.h:1410
bool AgeMortTest(void)
Ages the adult and applies a daily mortality probability.
Definition: Newt.cpp:768
static double m_NewtDormancyTemperature
Temperature in degrees that the newts become dormant.
Definition: Newt.h:338
Landscape * m_OurLandscape
Definition: PopulationManager.h:229

References AgeMortTest(), Calendar::Date(), g_date, Newt_Juvenile::m_NewtDormancyTemperature, TAnimal::m_OurLandscape, Landscape::SupplyTempPeriod(), toNewts_Die, toNewts_EvaluateLocation, and toNewts_Overwinter.

Referenced by Newt_Male::st_Develop(), and Newt_Female::st_Develop().

◆ st_Disperse()

TTypeOfNewtState Newt_Adult::st_Disperse ( void  )
protectedvirtual

Adult development state.

The newt can only move around when the humidity is high. Here we assume this is related to the rainfall and temperature of the preceeding days. If the humidity is high enough then the newt moves otherwise it stays where it is and returns toNewts_Develop.
The newt moves around using a random walk. At each step it evaluates if the habitat is walks onto is legal (if not it does not move), and if a pond it remembers this. The new pond is added to the m_pondlist vector.
The rate of the random walk is set by a input parameter stored in the static attribute m_newtwalkspeed. During the dispersal roads have associated mortality risks. These are flagged and probability tests taken.
If killed in dispersal, the current state will be changed to die by MoveTo->NewtDoWalking, so if this has been altered from toNewts_Dispersal then return the new state, otherwise returns toNewts_Develop. Note that adult dispersal in identical to juvenile dispersal, but differs in the distance assumed to be moved - which is reduced to 10% of the juvenile.

Reimplemented from Newt_Juvenile.

726  {
738  TTypeDirectedWalk directedness = directedwalk_random;
739  if (m_forcedisperse) directedness = directedwalk_high;
740  double temp = m_OurLandscape->SupplyTempPeriod(g_date->Date(), 5);
741  double humidity = m_OurLandscape->SupplyHumidity();
742  if ((temp > m_NewtDormancyTemperature) && (humidity > m_NewtDormancyHumidity))
743  {
746  }
747  return toNewts_Develop;
748 }
TTypeDirectedWalk
Newt types of movement.
Definition: Newt.h:80
@ directedwalk_high
Definition: Newt.h:82
@ directedwalk_random
Definition: Newt.h:85
@ toNewts_Develop
Definition: Newt.h:67
double SupplyHumidity(void)
Definition: landscape.h:1393
static int m_newtadultwalkspeed
The max walking speed of a newt.
Definition: Newt.h:419
TTypeOfNewtState m_CurrentNewtState
Variable to record current behavioural state.
Definition: Newt.h:113
static int m_newtwalkstepsize
The size of a step when evaluating habitat during walking.
Definition: Newt.h:332
bool m_forcedisperse
A flag to force dispersal from the breeding ponds.
Definition: Newt.h:371
static double m_NewtDormancyHumidity
Temperature in degrees that the newts become dormant.
Definition: Newt.h:340
void MoveTo(TTypeDirectedWalk a_directedness, int a_stepsize, int a_steps)
Top level control of newt movement.
Definition: Newt.cpp:509

References Calendar::Date(), directedwalk_high, directedwalk_random, g_date, Newt_Base::m_CurrentNewtState, Newt_Juvenile::m_forcedisperse, m_newtadultwalkspeed, Newt_Juvenile::m_NewtDormancyHumidity, Newt_Juvenile::m_NewtDormancyTemperature, Newt_Juvenile::m_newtwalkstepsize, TAnimal::m_OurLandscape, Newt_Juvenile::MoveTo(), Landscape::SupplyHumidity(), Landscape::SupplyTempPeriod(), toNewts_Develop, and toNewts_Die.

Referenced by Newt_Male::Step(), and Newt_Female::Step().

◆ st_EvaluateHabitat()

TTypeOfNewtState Newt_Adult::st_EvaluateHabitat ( void  )
protectedvirtual

Adult evaluate habitat behaviour.

The first thing to determine is whether this is the breeding season or not. This is controlled by the population manager. If it is breeding then:

  • Check if we are in a pond, if so return st_Breed
  • If not, then return migrate

If in a pond and after the NEWT_BREEDINGSEAONEND but before NEWT_BREEDINGSEAONEND+30 then it will disperse based on a probability which reaches unity by NEWT_BREEDINGSEAONEND+30. If its not the breeding season and not in pond then evaluate habitat and determine the dispersal necessity. This is identical to the juvenile st_EvaluateHabitat, which is what is called.

Reimplemented from Newt_Juvenile.

Reimplemented in Newt_Female, and Newt_Male.

780  {
791  int breedornot = m_OurPopulationManager->IsBreedingSeason();
792  if (breedornot == 0) {
793  if (m_InPond != -1) return toNewts_Breed;
794  else return toNewts_Migrate;
795  }
796  else
797  {
798  if (m_InPond)
799  {
800  if (breedornot > 30)
801  {
802  m_forcedisperse = true;
803  }
804  else if (g_rand_uni() < (breedornot / 30.0)) return toNewts_Develop;
805  }
806  }
808 }
@ toNewts_Migrate
Definition: Newt.h:72
@ toNewts_Breed
Definition: Newt.h:73
Newt_Population_Manager * m_OurPopulationManager
This is a time saving pointer to the correct population manager object.
Definition: Newt.h:119
virtual TTypeOfNewtState st_EvaluateHabitat(void)
Juvenile evaluate habitat behaviour.
Definition: Newt.cpp:472
int IsBreedingSeason()
Returns whether it is breeding season or not.
Definition: Newt_Population_Manager.h:87

References g_rand_uni, Newt_Population_Manager::IsBreedingSeason(), Newt_Juvenile::m_forcedisperse, Newt_Juvenile::m_InPond, Newt_Base::m_OurPopulationManager, Newt_Juvenile::st_EvaluateHabitat(), toNewts_Breed, toNewts_Develop, and toNewts_Migrate.

Referenced by Newt_Male::st_EvaluateHabitat().

◆ st_Migrate()

TTypeOfNewtState Newt_Adult::st_Migrate ( void  )
protectedvirtual

Adult migration to pond state.

The newt needs to return to its home pond or another on its list of ponds found if any. This requires a directed migration. Along the way the newt tests each step to see if it is a possible breeding location, or road mortality possibility.
First it tests to see if m_targetpondx is set, if its equal to -1 we have not target and need to aquire this. This is done by comparing the pondlist distances and picking the closest one.
Next the direction to the pond is needed. This is stored in m_OurVector, but may need updating.
The newt now needs to move towards the target pond. This is done using the standard newt movement code, but the stopping rule is that we get to a breeding pond, or that breeding season is over.

Calculates distance from location a_x, a_y. This is done using an approximation to pythagorus to avoid a speed problem.
NB this will crash if either a_dy or a_dx are zero, therefore the addition of 1!

820  {
829  if (m_targetpondx == -1) {
830  // Need to select the target pond
831  // Check each pond on our list to find the closest
832  APoint pt;
833  int range = m_SimW + m_SimH; // Too far
834  int index = 0;
835  for (unsigned p = 0; p < m_pondlist.size(); p++) {
839  int dist;
840  int dx = abs( m_Location_x - pt.m_x ) + 1;
841  int dy = abs(m_Location_y - pt.m_y) + 1;
842  if (dx>dy) dist = dx + (dy * dy) / (2 * dx); else dist = dy + (dx * dx) / (2 * dy);
843  if (dist <= range) {
844  range = dist;
845  index = p;
846  }
847  }
848  // Calculate the direction to the pond pointed to by index
850  m_targetpondx = pt.m_x;
851  m_targetpondy = pt.m_y;
852  }
853  int movedist;
854  int dx = abs(m_Location_x - m_targetpondx) + 1;
855  int dy = abs(m_Location_y - m_targetpondy) + 1;
856  if (dx>dy) movedist = dx + (dy * dy) / (2 * dx); else movedist = dy + (dx * dx) / (2 * dy);
857  if (movedist > m_newtwalkspeed) movedist = m_newtwalkspeed; else movedist = int(movedist*g_rand_uni()); // this is to prevent 'flipping' due to equal sized diagonal steps around the target
860  if (m_CurrentNewtState == toNewts_Die) return toNewts_Die; // If we died in movement
862  {
863  // We made it, so reset target and start breeding
864  m_targetpondx = -1;
866  // Now we turn the newts around to face out of the pond.
867  m_OurVector = (m_OurVector + 4) & 0x07;
868  return toNewts_Breed;
869  }
870  return toNewts_Develop;
871 }
@ directedwalk_totally
Definition: Newt.h:81
A simple class defining an x,y coordinate set.
Definition: ALMaSS_Setup.h:53
int m_y
Definition: ALMaSS_Setup.h:56
int m_x
Definition: ALMaSS_Setup.h:55
APoint SupplyCentroidIndex(int a_polyrefindex)
Definition: Landscape.cpp:771
void CalcMovementVector(void)
Calculates the direction needed to move in to get to the target pond.
Definition: Newt.cpp:874
static int m_SimW
The width of the simulation map, stored for fast access.
Definition: Newt.h:324
TTypesOfLandscapeElement m_CurrentHabitat
The current habitat type the newt is in.
Definition: Newt.h:369
static int m_newtwalkspeed
The max walking speed of a newt.
Definition: Newt.h:330
static int m_SimH
The height of the simulation map, stored for fast access.
Definition: Newt.h:326

References CalcMovementVector(), directedwalk_totally, g_rand_uni, Newt_Juvenile::m_CurrentHabitat, Newt_Base::m_CurrentNewtState, Newt_Juvenile::m_InPond, TAnimal::m_Location_x, TAnimal::m_Location_y, Newt_Juvenile::m_newtwalkspeed, Newt_Juvenile::m_newtwalkstepsize, TAnimal::m_OurLandscape, Newt_Juvenile::m_OurVector, Newt_Base::m_pondlist, Newt_Juvenile::m_SimH, Newt_Juvenile::m_SimW, m_targetpondx, m_targetpondy, APoint::m_x, APoint::m_y, Newt_Juvenile::MoveTo(), Landscape::SupplyCentroidIndex(), Landscape::SupplyPolyRefIndex(), tole_Pond, toNewts_Breed, toNewts_Develop, and toNewts_Die.

Referenced by Newt_Male::Step(), and Newt_Female::Step().

◆ st_Overwinter()

TTypeOfNewtState Newt_Adult::st_Overwinter ( void  )
protectedvirtual

Member Data Documentation

◆ m_AdultLifespan

unsigned Newt_Adult::m_AdultLifespan = cfg_NewtAdultLifespan.value()
static

The lifespan of the adult

Referenced by AgeMortTest().

◆ m_AdultPPPEffectProbability

double Newt_Adult::m_AdultPPPEffectProbability = cfg_NewtAdultPPPEffectProbability.value()
static

◆ m_AdultPPPElimRate

double Newt_Adult::m_AdultPPPElimRate = cfg_NewtAdultPPPToxEliminationRate.value()
static

The daily proportion of PPP body burden that is not eliminated for adults.

Referenced by Newt_Population_Manager::Newt_Population_Manager(), Newt_Male::st_Develop(), and Newt_Female::st_Develop().

◆ m_AdultPPPThreshold

double Newt_Adult::m_AdultPPPThreshold = cfg_NewtAdultPPPToxTrigger.value()
static

The threshold for effect of PPP on adults.

Newt_Adult adds the following attributes:

  • m_AdultLifespan which is the maximum lifespan of a newt, set a 14 years following Francillon-Vieillot (1990)
  • m_targetpondx which is the x-coordinate of the pond the newt decides to head to in migration
  • m_targetpondy which is the y-coordinate of the pond the newt decides to head to in migration

Four behavioural states are defined for the adult:

  • st_Develop which redefines the development state to take account of the adult rather than juvenile parameters
  • st_Overwinter which redefines the dormant state to use adult daily mortality
  • st_EvaluateHabitat which adds a breeding season test and the possibility to switch to migration or breeding behaviour
  • st_Migrate which returns the newt to its home pond or another on its list of ponds found if any

Referenced by Newt_Male::InternalPesticideHandlingAndResponse(), Newt_Female::InternalPesticideHandlingAndResponse(), and Newt_Population_Manager::Newt_Population_Manager().

◆ m_newtadultwalkspeed

int Newt_Adult::m_newtadultwalkspeed = cfg_NewtWalkSpeed.value()/10
static

The max walking speed of a newt.

Referenced by Newt_Population_Manager::Newt_Population_Manager(), and st_Disperse().

◆ m_targetpondx

int Newt_Adult::m_targetpondx
protected

x-coord of a target pond

Referenced by CalcMovementVector(), Init(), and st_Migrate().

◆ m_targetpondy

int Newt_Adult::m_targetpondy
protected

y-coord of a target pond

Referenced by CalcMovementVector(), Init(), and st_Migrate().


The documentation for this class was generated from the following files: